<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>协同后台管理系统</title>
	<meta name="decorator" content="default"/>
	<link rel="stylesheet" href="${ctxStatic}/css/plugins/wangEditor/wangEditor.min.css">
	<link href="${ctxStatic}/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
	<script src="${ctxStatic}/js/plugins/datapicker/bootstrap-datepicker.js"></script>
	<%@include file="/WEB-INF/views/include/treetable.jsp" %>
	<style>
		.datepicker.dropdown-menu{
			z-index: 20000;
		}
	</style>
	<script type="text/javascript">
        $(document).ready(function() {
          /*  $("#treeTable").treeTable({expandLevel : 3});*/
            $("#limitTime .input-daterange").datepicker({
                keyboardNavigation:false,
                forceParse:false,
                autoclose:true
            });
        });
	</script>
</head>
<body>
<div class="wrapper wrapper-content">
	<div class="row">
		<div class="col-sm-12">
		<div class="ibox float-e-margins">
			<%--<div class="ibox-title">
				<br/>
			</div>--%>

			<div class="ibox-content">
				<form:form id="inputForm" modelAttribute="article" action="${ctx}/cms/article/save" method="post" class="form-horizontal">
					<form:hidden path="id"/>
					<div class="form-group" style="margin-top: 50px;">
						<label class="col-sm-3 control-label"><span style="color: red;"><em>*</em></span>&nbsp;&nbsp;类目:</label>
						<div class="col-sm-8">
						<%--	<sys:treeselect id="category"  name="category.id" value="${article.category.id}" labelName="parent.name" labelValue="${article.category.name}"
											title="栏目" url="/cms/category/treeData?parentId=${parentId}" extId="${article.category.id}" cssClass=" form-control"/>--%>

							<sys:treeselect id="category"  name="category.id" value="${article.category.id}" labelName="parent.name" labelValue="${article.category.name}"
											title="栏目" url="/cms/category/treeData?parentId=${parentId}"  extId="${article.category.id}"   cssClass="required form-control"/>

						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"><span style="color: red;"><em>*</em></span>&nbsp;&nbsp;标题:</label>
						<div class="col-sm-8">
							<form:input path="title" id="title"  htmlEscape="false" maxlength="200" required="true" class="form-control" />
						</div>
					</div>

				<input type="hidden" id="parentId" value="${parentId}">
				<c:if test="${parentId==18}">
					<div class="form-group">
						<label class="col-sm-3 control-label">&nbsp;&nbsp;图片:</label>
						<div class="col-sm-8">
							<form:hidden id="image" path="image"  htmlEscape="false" maxlength="500" class="form-control"/>
							<sys:ckfinder input="image" type="thumb" uploadPath="/cms/articles"  selectMultiple="false"/>
							<span style="font-size: 12px;color:#9b9b9b">你可以上传jpg, png格式的文件, 图片建议尺寸240x200px，文件大小不能超过2M。</span>
						</div>
					</div>
				</c:if>

					<div class="form-group">
						<label class="col-sm-3 control-label"><span style="color: red;"><em>*</em></span>&nbsp;&nbsp;作者:</label>
						<div class="col-sm-8">
							<form:input path="author" id="author"  htmlEscape="false" maxlength="200" required="true" class="form-control" />
						</div>
					</div>

					<div class="form-group" id="limitTime">
						<label class="col-sm-3 control-label"><span style="color: red;"><em>*</em></span>&nbsp;&nbsp;发布时间:</label>
						<div class="input-daterange col-sm-3" id="datepicker">
							<input id="issueDate" name="issueDate" type="text" style="margin-top: 0!important;"  class="input-sm form-control"
								   value="<fmt:formatDate value="${article.issueDate}" pattern="yyyy-MM-dd"/>"  />

<%--
							<form:input path="issueDate" id="issueDate"  htmlEscape="false" maxlength="200"  class="form-control" />
--%>
						</div>

					</div>

				<%--	<div class="form-group">
						<label class="col-sm-3 control-label">图片上传: </label>
						<div class="col-sm-8">
							<form:hidden id="image" path="image"  htmlEscape="false" maxlength="500" class="form-control"/>
							<sys:ckfinder input="image" type="thumb" uploadPath="/cms/article"  selectMultiple="false"/>
							<span style="font-size: 12px;color:#9b9b9b">你可以上传jpg, png格式的文件, 图片建议尺寸至少为700x300px，文件大小不能超过2M。</span>
						</div>
					</div>--%>
					<div class="form-group">
						<label class="col-sm-3 control-label"><span style="color: red;"><em>*</em></span>&nbsp;&nbsp;正文内容:</label>
						<div class="col-sm-8">
								<div id="richText"></div>
						</div>
						<form:hidden path="articleData.content" id="articleDataContent" />

					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group" style="margin-top:30px">
						<div class="col-sm-8 col-sm-offset-3">
							<button style="margin-left: 100px;" type="button" class="btn btn-w-m btn-white" onclick="history.go(-1)">取消</button>
							<button id="btnSubmit" type="button" class="btn btn-w-m btn-primary">确定</button>
						</div>
					</div>
				</form:form>
			</div>
		</div>
	</div>
	</div>
</div>
<script src="${ctxStatic}/js/plugins/wangEditor/wangEditor.min.js"></script>
<script src="${ctxStatic}/js/plugins/validate/jquery.validate.min.js"></script>
<script src="${ctxStatic}/js/plugins/validate/messages_zh.min.js"></script>
<script src="${ctxStatic}/js/idenger.form.js"></script>
<script type="text/javascript">
    var editor = formTools.initEditer();//初始化配置富文本编辑器
    editor.customConfig.pasteFilterStyle = false;
    //获取后台传过来的值
    var articleDataContent = $("#articleDataContent").val();
    editor.txt.html(articleDataContent);
    $("#btnSubmit").click(function(){
        if($("#categoryName").val()==""){
            prompt.alert("请选择类目");
            return;
        }
        if($("#issueDate").val() == ""){
            prompt.alert("请选择时间");
            return;
        }
       /* if($("#parentId").val() == 18){
            if($("#image").val() == ""){
                prompt.alert("请选择图片");
                return;
            }
		}*/
        //获取富文本编辑器的内容
        $("#articleDataContent").val(editor.txt.html());
		var str = $("#articleDataContent").val();
        	str =  str.replace(/(^\s*)|(\s*$)/g, "");
        if(str == "<p><br></p>"){
            prompt.alert("请输入内容");
            return;
		}

        $("#inputForm").submit();
    });
</script>
</body>
</html>